<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:f="http://java.sun.com/jsf/core">

<h:head>
    <title>三一 - 问卷调查</title>
    <link href="../../css/component.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="../../js/highcharts.js"></script>
    <script type="text/javascript" src="../../js/drawChart.js"></script>
    <script type="text/javascript" src="../../js/drawChart2.js"></script>
</h:head>

<h:body>
    <ui:param name="bean" value="#{iosBillDataManager}"/>

    <span class="pagetitle">IOS账单管理--iOS账期数据</span>
    <p:separator/>

    <!-- 右侧页面顶部查询部分 -->
    <h:form id="fsearch">
        <p:growl id="growl" showDetail="true" sticky="true"/>
        <h:outputLabel id="radioHide" value="#{bean.dateRadio}" style="visibility: hidden"/>

        <p:outputPanel id="customPanel" style="margin-bottom:10px">
            <p:selectOneRadio id="customRadio" value="#{bean.dateRadio}" layout="custom">
                <f:selectItem itemLabel="7" itemValue="7"/>
                <f:selectItem itemLabel="15" itemValue="15"/>
                <f:selectItem itemLabel="30" itemValue="30"/>
                <f:selectItem itemLabel="0" itemValue="0"/>
                <p:ajax update="radioHide customPanel :#{p:component('dform')}" listener="#{bean.radioChange}"/>
            </p:selectOneRadio>

            <h:panelGrid id="opt" columns="14" cellpadding="5">
                <p:radioButton id="opt1" for="customRadio" itemIndex="0"/>
                <h:outputLabel for="opt1" value="近7天"/>
                <h:outputLabel/>

                <p:radioButton id="opt2" for="customRadio" itemIndex="1"/>
                <h:outputLabel for="opt2" value="近15天"/>
                <h:outputLabel/>

                <p:radioButton id="opt3" for="customRadio" itemIndex="2"/>
                <h:outputLabel for="opt3" value="近30天"/>
                <h:outputLabel/>

                <p:radioButton id="opt4" for="customRadio" itemIndex="3"/>
                <h:outputLabel for="opt4" value="自定义 开始时间"/>
                <p:calendar value="#{bean.dateStart}" mode="popup" pattern="yyyy-MM-dd" />
                <h:outputLabel for="opt4" value="结束时间"/>
                <p:calendar value="#{bean.dateEnd}" mode="popup" pattern="yyyy-MM-dd" />
            </h:panelGrid>
        </p:outputPanel>

        <p:commandButton value="查询" action="#{bean.search()}" update=":data" ajax="false"/>
    </h:form>
    <br/>
    <!-- 数据展示部分，包含表格和图表 -->
    <h:form id="dform">
        <div class="data" id="data">
            <p:panel id="panel1" header="退款详细数据" style="margin-bottom:10px;">
                <p:dataGrid id="chart1" var="c" value="#{bean.chartByDate}" columns="1" layout="grid" rendered="false">
                    <p:panel style="text-align:center">
                        <h:panelGrid columns="1" style="width:100%">
                            <div id="highchartChart1" style="width:100%;height:350px; border:0;">
                                <script type="text/javascript">
                                    generateChart('#{c.jsonStr}', '#{c.jsonType}', '1');
                                </script>
                            </div>
                        </h:panelGrid>
                    </p:panel>
                </p:dataGrid>
                <br/>

                <h:commandLink rendered="#{bean.dates != null and bean.dates.size() > 0}">
                    <p:graphicImage url="/resources/images/excel.png" height="25px"/>
                    <p:dataExporter type="xls" target="dlist1"
                                    fileName="datasByDate-#{pageHelper.getNewDateDetailStr()}"/>
                </h:commandLink>
                <p:dataTable id="dlist1" var="l" value="#{bean.dates}" scrollable="true" resizableColumns="true"
                             paginator="true" paginatorPosition="top"
                             paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown} "
                             rowsPerPageTemplate="10,20,30" rows="10" style="text-align:center;">
                    <p:columnGroup type="header">
                        <p:row>
                            <p:column rowspan="2" headerText="日期" styleClass="column grcnewUser"/>
                            <c:forEach items="#{bean.productids}" var="entry">
                                <p:column colspan="2" headerText="#{entry}" styleClass="column twoUser"/>
                            </c:forEach>
                        </p:row>
                        <p:row>
                            <c:forEach items="#{bean.productids}" var="entry">
                                <p:column headerText="IOS收入" styleClass="column"/>
                                <p:column headerText="IOS退款" styleClass="column"/>
                            </c:forEach>
                        </p:row>
                    </p:columnGroup>

                    <p:column styleClass="column grcnewUser">
                        <h:outputText value="#{l}"/>
                    </p:column>
                    <c:forEach items="#{bean.productids}" var="entry">
                        <p:column styleClass="column">
                            <h:outputText value="#{bean.getBillData(l, entry, false).iosin}"/>
                        </p:column>
                        <p:column styleClass="column">
                            <h:outputText value="#{bean.getBillData(l, entry, false).iosreturn}"/>
                        </p:column>
                    </c:forEach>

                    <p:columnGroup type="footer">
                        <p:row>
                            <p:column footerText="汇总" styleClass="column grcnewUser"/>
                            <c:forEach items="#{bean.productids}" var="entry">
                                <p:column footerText="#{bean.getBillData('', entry, true).iosin}" styleClass="column lessUser"/>
                                <p:column footerText="#{bean.getBillData('', entry, true).iosreturn}" styleClass="column lessUser"/>
                            </c:forEach>
                        </p:row>
                    </p:columnGroup>
                </p:dataTable>
            </p:panel>
            <br/>

            <p:panel id="panel2" header="退款汇总数据" style="margin-bottom:10px;">
                <p:dataGrid id="chart2" var="c" value="#{bean.chartByAll}" columns="1" layout="grid" rendered="false">
                    <p:panel style="text-align:center">
                        <h:panelGrid columns="1" style="width:100%">
                            <div id="highchartChart2" style="width:100%;height:350px; border:0;">
                                <script type="text/javascript">
                                    generateChart('#{c.jsonStr}', '#{c.jsonType}', '2');
                                </script>
                            </div>
                        </h:panelGrid>
                    </p:panel>
                </p:dataGrid>
                <br/>

                <h:commandLink rendered="#{bean.datasByAll != null and bean.datasByAll.size() > 0}">
                    <p:graphicImage url="/resources/images/excel.png" height="25px"/>
                    <p:dataExporter type="xls" target="dlist2"
                                    fileName="datasByAll-#{pageHelper.getNewDateDetailStr()}"/>
                </h:commandLink>
                <p:dataTable id="dlist2" var="l" value="#{bean.datasByAll}" scrollable="true" resizableColumns="true"
                             paginator="true" paginatorPosition="top"
                             paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown} "
                             rowsPerPageTemplate="10,20,30" rows="10" style="text-align:center;">
                    <p:column headerText="商品" styleClass="column" style="width:80px">
                        <h:outputLabel value="#{l.productname}" />
                    </p:column>
                    <p:column headerText="BI收入" styleClass="column" style="width:80px" rendered="false">
                        <h:outputLabel value="#{l.bi}" />
                    </p:column>
                    <p:column headerText="IOS收入（美分）" styleClass="column" style="width:80px">
                        <h:outputLabel value="#{l.iosin}" />
                    </p:column>
                    <p:column headerText="IOS退款（美分）" styleClass="column" style="width:80px">
                        <h:outputLabel value="#{l.iosreturn}" />
                    </p:column>
                    <p:column headerText="退款比例" styleClass="column" style="width:80px">
                        <h:outputLabel value="#{pageHelper.double2Percent(l.iosPerBi)}" />
                    </p:column>
                </p:dataTable>
            </p:panel>
            <br/>

            <p:panel id="panel3" header="退款月度对比数据" style="margin-bottom:10px;">
                <p:calendar value="#{bean.monthStart}" mode="popup" pattern="yyyy-MM" />
                -
                <p:calendar value="#{bean.monthEnd}" mode="popup" pattern="yyyy-MM" />
                &#160;&#160;&#160;

                <p:commandButton value="查询" action="#{bean.searchMonth()}" update="panel3" ajax="true" />

                <p:dataGrid id="chart3" var="c" value="#{bean.chartByMonth}" columns="1" layout="grid" rendered="false">
                    <p:panel style="text-align:center">
                        <h:panelGrid columns="1" style="width:100%">
                            <div id="highchartChart3" style="width:100%;height:350px; border:0;">
                                <script type="text/javascript">
                                    generateChart('#{c.jsonStr}', '#{c.jsonType}', '3');
                                </script>
                            </div>
                        </h:panelGrid>
                    </p:panel>
                </p:dataGrid>
                <br/>

                <h:commandLink rendered="#{bean.datasByMonth != null and bean.datasByMonth.size() > 0}">
                    <p:graphicImage url="/resources/images/excel.png" height="25px"/>
                    <p:dataExporter type="xls" target="dlist3"
                                    fileName="datasByMonth-#{pageHelper.getNewDateDetailStr()}"/>
                </h:commandLink>

                <p:dataTable id="dlist3" var="l" value="#{bean.datasByMonth}" scrollable="true" rowIndexVar="rowIndex" resizableColumns="true"
                             paginator="false" paginatorPosition="top"
                             paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown} "
                             rowsPerPageTemplate="10,20,30" rows="10" style="text-align:center;">
                    <p:column headerText="商品" styleClass="column">
                        <h:outputLabel value="#{l.productname}" />
                    </p:column>
                    <p:column headerText="#{l.biStr}" styleClass="column"  rendered="false">
                        <h:outputLabel value="#{l.bi}" />
                    </p:column>
                    <p:column headerText="#{l.biStr2} BI收入" styleClass="column"  rendered="false">
                        <h:outputLabel value="#{l.bi2}" />
                    </p:column>
                    <p:column headerText="#{l.iosinStr} IOS收入（美分）" styleClass="column">
                        <h:outputLabel value="#{l.iosin}" />
                    </p:column>
                    <p:column headerText="#{l.iosinStr2} IOS收入（美分）" styleClass="column">
                        <h:outputLabel value="#{l.iosin2}" />
                    </p:column>
                    <p:column headerText="#{l.iosreturnStr} IOS退款（美分）" styleClass="column">
                        <h:outputLabel value="#{l.iosreturn}" />
                    </p:column>
                    <p:column headerText="#{l.iosreturnStr2} IOS退款（美分）" styleClass="column">
                        <h:outputLabel value="#{l.iosreturn2}" />
                    </p:column>
                    <p:column headerText="#{l.iosPerBiStr} 退款比例" styleClass="column">
                        <h:outputLabel value="#{pageHelper.double2Percent(l.iosPerBi)}" />
                    </p:column>
                    <p:column headerText="#{l.iosPerBiStr2} 退款比例" styleClass="column">
                        <h:outputLabel value="#{pageHelper.double2Percent(l.iosPerBi2)}" />
                    </p:column>
                </p:dataTable>
            </p:panel>
        </div>
    </h:form>

    <!-- 页脚 -->
    <div class="footer"></div>
</h:body>
</html>